/**
*交直流配电js
*/ 

var	acdcDS;
var acdcFormPanel;
function doAcdcDelete(id)
{
	Ext.MessageBox.confirm('确认删除', '确认删除该信息?', 
	function(btn) {
		if(btn == 'yes') // 选中了是按钮	
		{
			JAcdcDistributionWeb.deleteAcdcDistributionBO(id,function(data)
			{
				if(data)
				{ 
					Ext.Msg.alert('成功',"操作成功！"); 
					acdcDS.load({params:{start:0,limit:17,'<%=Constant.BTS_CODE%>':'<%=strbtscode%>'}});	 
					//acdcFormPanel.getForm().reset();			
				}else
				{
					Ext.Msg.alert("失败","操作失败!");
				}
			})
		}
	})	
}


Ext.onReady(function(){  
	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'side';

	var acdcType = Ext.data.Record.create([								
							   {name: 'id', type: "string"},
							   {name: 'btscode', type: "string"},
							   {name: 'btsname', type: "string"},
							   {name: 'distmanufacturer', type: "string"},
							   {name: 'disttype', type: "string"},
							   {name: 'distother', type: "string"},
							   {name: 'airswitchM',  type: 'string'},
							   {name: 'airswitchT', type: "string"},
							   {name: 'airswitchC', type: "string"},
							   {name: 'airswitchO', type: 'string'},
							   {name: 'airswitchCRD', type: 'string'},
							   {name: 'elecableDANum',  type: 'string'},
							   {name: 'elecableDALen',  type: 'string'},
							   {name: 'elecableDACRD',  type: 'string'},
							   {name: 'regulatorM',  type: 'string'},
							   {name: 'regulatorT',  type: 'string'},
							   {name: 'regulatorC',  type: 'string'},
							   {name: 'regulatorOT',  type: 'date'},
							   {name: 'regulatorCRD',  type: 'string'},
							   {name: 'lighting',  type: 'string'},
							   {name: 'socket',  type: 'string'},
							   {name: 'elecableCPS',  type: 'string'},
							   {name: 'elecableCPT',  type: 'string'},
							   {name: 'elecableCPNum',  type: 'string'},
							   {name: 'elecableCPLen',  type: 'string'},
							   {name: 'elecableCPCRD',  type: 'string'},
							   {name: 'DDConverterT',  type: 'string'},
							   {name: 'DDConverterM',  type: 'string'},
							   {name: 'DDConverterNum',  type: 'string'},
							   {name: 'DDConverterC',  type: 'string'},
							   {name: 'DDConverterOT',  type: 'date'},
							   {name: 'DDConverterCRD',  type: 'string'},
							   {name: 'DDisplayT',  type: 'string'},
							   {name: 'DDisplayM',  type: 'string'},
							   {name: 'DDisplayNum',  type: 'string'},
							   {name: 'DDisplayC',  type: 'string'},
							   {name: 'DDisplayOT',  type: 'date'},
							   {name: 'maintenance',  type: 'string'},
							   {name: 'refreshtime',  type: 'date'},
							   {name: 'memo',  type: 'string'}
						 ]); 
	var acdcCM = new Ext.grid.ColumnModel(
			[
				new Ext.grid.CheckboxSelectionModel({singleSelect: true}), 	            
				{header: "流水号", sortable: true, dataIndex: 'id',align:'left'},
				{header: "基站编号", sortable: true, dataIndex: 'btscode',align:'left'},
				{header: "基站名称",  sortable: true, dataIndex: 'btsname',align:'left'},	
				{header: "厂家",  sortable: true, dataIndex: 'distmanufacturer',align:'left'} 				
			]
		);				 
	
	function showDelete(id)
	{
		return "<input type='button' value='删除' class='x-btn button' onclick='doAcdcDelete(\"" + id  +   "\")'>";  
	}
	
	
	
	acdcDS = new Ext.data.Store({
				proxy: new Ext.data.DWRProxy(JAcdcDistributionWeb.getAcdcDistributionList, true),	
				reader: new Ext.data.ListRangeReader({
					totalProperty: 'totalSize',
					id: 'id'
				}, acdcType),
				sortInfo:{field:'id', direction:'ASC'}// 排序信息
			});

	
	var towerMountedGridDiv = Ext.get("mainTabPanelDIV");
	var acdcGrid = new Ext.grid.GridPanel({			 	
			ds: acdcDS,
			cm: acdcCM, 
			sm: new Ext.grid.RowSelectionModel({
                    singleSelect: true,
                    listeners: {
                        rowselect: function(sm, row, rec) {
                            acdcFormPanel.getForm().loadRecord(rec);
							airButton.enable(); 
							eleButton.enable();
                        }
                    }
                }),
			autoWidth : true,  
			autoScroll : true,  
			autoHeight　: false,
			region : 'center',
			height: 400,
			minSize: 200,		
			frame:true,
			collapsible:false, 
			enableDragDrop:false, 		
			bbar: new Ext.PagingToolbar({
					pageSize: 17,
					store: acdcDS,
					displayInfo: true,
					displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
					emptyMsg: "没有记录"
				})
		});
		
	acdcDS.on('load', function() {
		acdcGrid.getSelectionModel().selectFirstRow(); 
	});	

	var cType = Ext.data.Record.create([								
							   {name: 'id', type: "string"},
							   {name: 'acdcid', type: "string"}, 
							   {name: 'distmanufacturer', type: "string"}, 
							   {name: 'ptype',  type: 'string'},
							   {name: 'num',  type: 'string'},
							   {name: 'len',  type: 'string'},
							   {name: 'other',  type: 'string'},
							   {name: 'record',  type: 'string'},
							   {name: 'meno',  type: 'string'},
							   {name: 'userful',  type: 'string'},
							   {name: 'recordtype',  type: 'string'}
						 ]); 
	var cSM = new Ext.grid.CheckboxSelectionModel({singleSelect: true});						
	var cCM = new Ext.grid.ColumnModel(
			[    
				cSM, 	
				{header: "厂家", width: 130, dataIndex: 'distmanufacturer',align:'left'},	
				{header: "电源类型", width: 100, dataIndex: 'ptype',align:'left'},
				{header: "数量/容量", width: 100, dataIndex: 'num',align:'left'},
				{header: "长度", width: 100, dataIndex: 'len',align:'left'},
				{header: "其他", width: 100, dataIndex: 'other',align:'left'},
				{header: "更换记录", width: 100, dataIndex: 'record',align:'left'},
				{header: "电缆用途", width: 100, dataIndex: 'userful',align:'left'},
				{header: "备注", width: 100, dataIndex: 'meno',align:'left'}
			]
		);				 
	
	function showCDelete(id)
	{
		//return "<input type='button' value='删除' class='x-btn button' onclick='doStorageBatteryDelete(\"" + id  +   "\")'>";  
	}
	var cDS = new Ext.data.Store({
				proxy: new Ext.data.DWRProxy(JAcdcDistributionWeb.getAcdcDistributionMapList, true),	
				reader: new Ext.data.ListRangeReader({
					totalProperty: 'totalSize',
					id: 'id'
				}, cType),
				sortInfo:{field:'id', direction:'ASC'}// 排序信息
			});
		 
	var cGrid = new Ext.grid.EditorGridPanel({			 	
			ds: cDS,
			cm: cCM, 
			autoWidth : true,  
			autoScroll : true,  
			autoHeight　: false,
			region : 'center',
			width:200,
			height: 250,
			minSize: 200,		
			frame:true,
			clicksToEdit:2,
			sm: cSM,
			 
				
			bbar: new Ext.PagingToolbar({
					pageSize: 17,
					store: cDS,
					displayInfo: true,
					displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
					emptyMsg: "没有记录"
				})
		});
	
	function onAdd(){		
		var data = {};			
		var record = new Ext.data.Record(data);
		if(recordType == "AIRS")
		{
			acdcAirWindow.show();
			acdcAirWindow.formPanel.getForm().loadRecord(record);
		}else
		{
			acdcEleWindow.show();
			acdcEleWindow.formPanel.getForm().loadRecord(record);
		}		
	}
	function onEdit(){
		var record = cGrid.getSelectionModel().getSelected();
		if(!record)
		{
			Ext.Msg.alert("提示","请先选择交直流配电信息 !");
			return;
		}
		if(recordType == "AIRS")
		{
			acdcAirWindow.show();
			acdcAirWindow.formPanel.getForm().loadRecord(record);
		}else
		{
			acdcEleWindow.show();
			acdcEleWindow.formPanel.getForm().loadRecord(record);
		}
	}
	
	function onDelete(){
		var record = cGrid.getSelectionModel().getSelected();
		if(!record)
		{
			Ext.Msg.alert("提示","请先选择交直流配电信息 !");
			return;
		}
		JAcdcDistributionWeb.deleteAcdcDistributionMap(record.get("id"),function(data)
		{
			if(data)
			{ 
				Ext.Msg.alert('成功',"操作成功！",function()
				{
					loadEleAndAirdata(cDS,acdcGrid.getSelectionModel().getSelected().get("id"),recordType);		
				});  
			}else
			{
				Ext.Msg.alert("失败","操作失败!");
			}																
		})	
	}
	
	var win = new Ext.Window({ 
					layout:'fit',
					width:750,
					height:400,
					closeAction:'hide',
					plain: true,
					modal:true,
					items:cGrid,		
					buttons: [
						{
							text:'确&nbsp;&nbsp;定',
							handler: function()
							{								 
								win.hide();
							}
						}]
				});
	var airButton = new Ext.Button({
						pressed : true,
	                    enableToggle : true,
	                    text : '空 开 数 据',
						itemCls:'win-first',  
						clearCls:'allow-float', 
	                    toggleHandler:doShow
			});
	airButton.disable();

	var eleButton = new Ext.Button({
						pressed : true,
	                    enableToggle : true,
	                    text : '电缆使用情况',
	                    toggleHandler:doShowEle
			});
	airButton.disable();
	eleButton.disable();	
		
	function doShow()
	{
		var record = acdcGrid.getSelectionModel().getSelected();
		if(!record)
		{
			Ext.Msg.alert("提示","请先选择交直流配电信息 !");
			return;
		}	
		win.show();	
		loadAirdata(cDS,record.get("id"));	
		
		cCM.setHidden( 1,false);
		cCM.setColumnHeader(1,"厂家");
		cCM.setHidden( 2,false);
		cCM.setColumnHeader(2,"型号");
		cCM.setHidden( 3,false);
		cCM.setHidden( 4,true);
		cCM.setHidden( 5,false);
		cCM.setHidden( 6,false);
		cCM.setHidden( 7,true);
		cCM.setHidden( 8,true);
	}
	
	function doShowEle()
	{
		var record = acdcGrid.getSelectionModel().getSelected();
		if(!record)
		{
			Ext.Msg.alert("提示","请先选择交直流配电信息 !");
			return;
		}	
		win.show();	
		loadEledata(cDS,record.get("id"));	
		cCM.setHidden( 1,false);
		cCM.setColumnHeader(1,"电缆规格");
		cCM.setHidden( 2,false);
		cCM.setColumnHeader(2,"电缆型号");
		cCM.setHidden( 3,false);
		cCM.setHidden( 4,false);
		cCM.setHidden( 5,true);
		cCM.setHidden( 6,false);
		cCM.setHidden( 7,false);
		cCM.setHidden( 8,false); 
	}
	
	
	// Setup the form panel
	acdcFormPanel = new Ext.form.FormPanel({
		region     : 'south', 
		bodyStyle  : 'padding: 10px; background-color: #DFE8F6',  
		height: 200,
		minSize: 200,
		maxSize: 250,
		frame:true,
		buttonAlign:'right',
		layout:'column', 
		items:[
			{
				layout:'column', 
				items:[
					 {
						columnWidth:.30,
						layout: 'form',  
						labelWidth:70,	 
						labelAlign:'right',	
						items: [
							{
								xtype:'hidden',
								fieldLabel: '流水号',
								width:250,
								name: 'id'
							}, {
								xtype:'textfield', 
								fieldLabel: '基站编号', 
								width:200,
								disabled:true,
								name: 'btscode'
							}]
					 },
					 {
						columnWidth:.30,
						layout: 'form',  
						labelAlign:'right',	
						labelWidth:70,	 
						items: [
							{ 
								xtype:'textfield',
								fieldLabel: '基站名称',
								width:200,
								disabled:true,
								readOnly: true,
								name: 'btsname'
							}]
					 },
					 {
						columnWidth:.40,
						layout: 'form',  
						labelAlign:'right',	
						labelWidth:70,	 
						margins:'0 0 0 100',
						items: [ airButton,eleButton]
					 }
				]
			},
			{
				xtype:'tabpanel',
				plain:true,
				activeTab: 0,
				height:120, 
				deferredRender: false,
				defaults:{bodyStyle:'padding:10px'},
				items:[
					{
						title:'配电箱',
						frame:true,
						labelAlign:'right',
						layout:'column', 
						items:[
							 {
								columnWidth:.33,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:100,	 
								items: [
									{
										xtype:'textfield', 
										fieldLabel: '厂家', 										
										width:100,
										disabled:true,
										name: 'distmanufacturer'
									}]
							 },
							 {
								columnWidth:.33,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:70,	 
								items: [
									{
										xtype:'textfield',
										fieldLabel: '型号',
										width:100,
										disabled:true,
										name: 'disttype'
									}]
							 },
							 {
								columnWidth:.34,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:70,	 
								items: [
									{
										xtype:'textfield',
										fieldLabel: '其它',
										width:100, 
										disabled:true,
										name: 'distother'
									}]
							 }
						]
					},{
						title:'稳压器',
						frame:true,
						layout:'column', 
						labelAlign :'right',
						items:[
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:100,	 
								items: [
									{
										xtype:'textfield', 
										fieldLabel: '厂家', 
										width:100,
										disabled:true,
										name: 'regulatorM'
									},{
										xtype:'textfield', 
										fieldLabel: '更换及维修记录', 
										width:100,
										disabled:true,
										name: 'regulatorCRD'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:70,	 
								items: [
									{
										xtype:'textfield',
										fieldLabel: '型号',
										width:100,
										disabled:true,
										name: 'regulatorT'
									},{
										xtype:'textfield',
										fieldLabel: '照明',
										width:100,
										disabled:true,
										name: 'lighting'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:70,	 
								items: [
									{
										xtype:'textfield',
										fieldLabel: '型号容量',
										width:100,
										disabled:true,
										name: 'regulatorC'
									},{
										xtype:'textfield',
										fieldLabel: '插座',
										width:100,
										disabled:true,
										name: 'socket'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:70,	 
								items: [
									{
										xtype:'datefield',
										format : "Y-m-d",
										//allowBlank:false,
										fieldLabel: '启用时间',
										width:100,
										disabled:true,
										name: 'regulatorOT'
									}]
							 }
						]
					},{
						title:'DC/DC转换器',
						frame:true,
						layout:'column', 
						labelAlign :'right',
						items:[
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:100,	 
								items: [
									{
										xtype:'textfield', 
										fieldLabel: '规格型号', 
										width:100,
										disabled:true,
										name: 'DDConverterT'
									},{
										xtype:'datefield',
										format : "Y-m-d",
										//allowBlank:false,
										fieldLabel: '启用时间', 
										width:100,
										disabled:true,
										name: 'DDConverterOT'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:100,	 
								items: [
									{
										xtype:'textfield',
										fieldLabel: '厂家',
										width:100,
										disabled:true,
										name: 'DDConverterM'
									},{
										xtype:'textfield',
										fieldLabel: '更换及维修记录',
										width:100,
										disabled:true,
										name: 'DDConverterCRD'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form', 
								labelAlign:'right',									
								labelWidth:70,	 
								items: [
									{
										xtype:'numberfield',
										fieldLabel: '数量',
										value:1,
										width:100,
										disabled:true,
										name: 'DDConverterNum'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form', 
								labelAlign:'right',			
								labelWidth:70,	 
								items: [
									{
										xtype:'numberfield',
										fieldLabel: '容量',
										value:1,
										width:100,
										disabled:true,
										name: 'DDConverterC'
									}]
							 }
						]
					},{
						title:'直流配电屏',
						frame:true,
						layout:'column', 
						labelAlign :'right',
						items:[
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:100,	 
								items: [
									{
										xtype:'textfield', 
										fieldLabel: '规格型号', 
										width:100,
										disabled:true,
										name: 'DDisplayT'
									},{
										xtype:'datefield',
										format : "Y-m-d",
										//allowBlank:false,
										fieldLabel: '启用时间', 
										width:100,
										disabled:true,
										name: 'DDisplayOT'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:100,	 
								items: [
									{
										xtype:'textfield',
										fieldLabel: '厂家',
										width:100,
										disabled:true,
										name: 'DDisplayM'
									},{
										xtype:'textfield',
										fieldLabel: '更换及维修记录',
										width:100,
										disabled:true,
										name: 'maintenance'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:70,	 
								items: [
									{
										xtype:'numberfield',
										fieldLabel: '数量',
										value:1,
										width:100,
										disabled:true,
										name: 'DDisplayNum'
									},{
										xtype:'textarea',
										fieldLabel: '备注',
										width:100,
										disabled:true,
										name: 'memo'
									}]
							 },
							 {
								columnWidth:.25,
								layout: 'form',  
								labelAlign:'right',	
								labelWidth:70,	 
								items: [
									{
										xtype:'numberfield',
										fieldLabel: '容量',
										value:1,
										width:100,
										disabled:true,
										name: 'DDisplayC'
									}]
							 }
						]
					}]
			}	 
			] 	
	});



	//Simple 'border layout' panel to house both grids
	
	var displayPanel = new Ext.Panel({
		width    : towerMountedGridDiv.getComputedWidth(),
		height   : 500,
		layout   : 'border',
		renderTo : 'AcdcdistributionTab',
		items    : [
			acdcGrid,
			acdcFormPanel
		]
	});
	
	
	function saveAcdc()
	{
		if (!acdcFormPanel.getForm().isValid())
			return;	
			
		var form = acdcFormPanel.getForm().getValues(false);	
		var acdcBO = {};
		acdcBO.id = form.id;
		acdcBO.btscode = form.btscode;
		acdcBO.btsname= form.btsname;
		acdcBO.distmanufacturer = form.distmanufacturer;		
		acdcBO.disttype = form.disttype;
		acdcBO.distother = form.distother;
		acdcBO.airswitchM = form.airswitchM;
		acdcBO.airswitchT = form.airswitchT;
		acdcBO.airswitchC = form.airswitchC;
		acdcBO.airswitchO = form.airswitchO;
		acdcBO.airswitchCRD = form.airswitchCRD; 
		//acdcBO.elecableDAS = form.elecableDAS;
		//acdcBO.elecableDAT = form.elecableDAT; 
		//acdcBO.elecableDANum = form.elecableDANum; 
		//acdcBO.elecableDALen = form.elecableDALen; 
		//acdcBO.elecableDACRD = form.elecableDACRD; 
		acdcBO.regulatorM = form.regulatorM; 
		acdcBO.regulatorT = form.regulatorT; 
		acdcBO.regulatorC = form.regulatorC; 
		
		var regulatorOT = form.regulatorOT; 
		if(regulatorOT != "undefined" && regulatorOT != "")
		{
			var opentimeDate = new Date();	
			var arrPlanTime = regulatorOT.split("-");						
			var yearOth = arrPlanTime[0];
			var monthOth = arrPlanTime[1];
			var dayOth = arrPlanTime[2];
			opentimeDate.setFullYear(yearOth,monthOth-1,dayOth);			
			acdcBO.regulatorOT = opentimeDate;
		}else
			acdcBO.regulatorOT = new Date();
		
		
		acdcBO.regulatorCRD = form.regulatorCRD; 
		acdcBO.lighting = form.lighting; 
		acdcBO.socket = form.socket; 
		//acdcBO.elecableCPS = form.elecableCPS;
		//acdcBO.elecableCPT = form.elecableCPT; 
		//acdcBO.elecableCPNum = form.elecableCPNum; 
		//acdcBO.elecableCPLen = form.elecableCPLen; 
		//acdcBO.elecableCPCRD = form.elecableCPCRD; 
		acdcBO.DDConverterT = form.DDConverterT; 
		acdcBO.DDConverterM = form.DDConverterM; 
		acdcBO.DDConverterNum = form.DDConverterNum; 
		acdcBO.DDConverterC = form.DDConverterC; 
		var dDConverterOT = form.DDConverterOT;
		if(dDConverterOT != "undefined" && dDConverterOT != "")
		{
			var opentimeDate = new Date();	
			var arrPlanTime = dDConverterOT.split("-");						
			var yearOth = arrPlanTime[0];
			var monthOth = arrPlanTime[1];
			var dayOth = arrPlanTime[2];
			opentimeDate.setFullYear(yearOth,monthOth-1,dayOth);
			
			acdcBO.DDConverterOT = opentimeDate;
		}else
			acdcBO.DDConverterOT = new Date();
		
		acdcBO.DDConverterCRD = form.DDConverterCRD; 
		acdcBO.DDisplayT = form.DDisplayT; 
		acdcBO.DDisplayM = form.DDisplayM;
		acdcBO.DDisplayNum = form.DDisplayNum; 
		acdcBO.DDisplayC = form.DDisplayC; 
		
		var dDisplayOT = form.DDisplayOT;	
		if(dDisplayOT != "undefined" && dDisplayOT != "")
		{
			var opentimeDate = new Date();	
			var arrPlanTime = dDisplayOT.split("-");						
			var yearOth = arrPlanTime[0];
			var monthOth = arrPlanTime[1];
			var dayOth = arrPlanTime[2];
			opentimeDate.setFullYear(yearOth,monthOth-1,dayOth);			
			acdcBO.DDisplayOT = opentimeDate;
		}else
			acdcBO.DDisplayOT =  new Date();
		
		acdcBO.maintenance = form.maintenance; 
		acdcBO.memo = form.memo;  
			
		JAcdcDistributionWeb.saveAcdcDistributionBO(acdcBO,function(data)
		{
			if(data)
			{ 
				Ext.Msg.alert('成功',"操作成功！"); 
				loadDate(acdcDS,acdcFormPanel);		 
			}else
			{
				Ext.Msg.alert("失败","操作失败!");
			}
		})
			
	}
	
	loadDate(acdcDS,acdcFormPanel);	
	
 		
	
	var acdcAirForm = new Ext.FormPanel({
			//renderTo:'changeTab',
	    	labelAlign: 'right',
	        frame:true,	        
	        labelWidth:150,	       
			anchor:'90%',
			region:'center',
			height: 360,
			minSize: 200,	
			align:'center',
			buttonAlign:'center', 
			border: false, 
			style: 'margin:0 auto',
			layout:'form', 
			margins:'55 35 100 35',	
	        items: [  
					{
						xtype : 'hidden',
						fieldLabel : "id",
						readOnly : true,
						name : "id"
					},
					{
						xtype : 'hidden',
						fieldLabel : "acdcid",
						readOnly : true,
						name : "acdcid"
					},
					{
						xtype:'textfield',
						fieldLabel:'厂家',
						emptyText:'厂家',
						name : 'distmanufacturer',
						width : 200,
						allowBlank : false,
						blankText : '请输入厂家名称'
					},{
						xtype:'textfield',
						fieldLabel:'型号',
						 emptyText:'型号',
						 name : 'ptype',
						 width : 200,
						 allowBlank : false,
						 blankText : '请输入型号'
					},{
						xtype:'numberfield',
						fieldLabel:'容量',
						emptyText:'容量',
						name : 'num',
						width : 200,
						decimalPrecision:2,
						value:0,
						allowBlank : false,
						blankText : '请输入容量'
					},{
						xtype:'textfield', 
						fieldLabel: '整治及更换记录',
						name: 'record',
						width:200, 	 
						//allowBlank:false,
						blankText :'请输入更换记录'
					},{
						xtype:'textfield',
						 fieldLabel:'其他',
						 emptyText:'其他',
						 name : 'other',
						 width : 200
					} 			 
				]		
		}); 
	
var AcdcAirWindow = function() {
		var _win = this;
		this.formPanel = acdcAirForm;
		var _form = this.formPanel.getForm();
		AcdcAirWindow.superclass.constructor.call(this, { 
			title: '空开数据',
			width : 450,
			height : 230,
			resizable : true,
			plain : false,
			border : false,
			modal : true,
			autoScroll : false,
			layout : 'fit',
			closeAction : 'hide',
			items : this.formPanel,
			buttonAlign:'center',
			buttons : 
			[
				{	text : ' 保存',
					handler : function() 
					{
						if (_form.isValid()) 
						{
							var form = _form.getValues(false);
							 
							AcdcDistributionMapBO = {};
							AcdcDistributionMapBO.id = form.id;	
							AcdcDistributionMapBO.acdcid = acdcGrid.getSelectionModel().getSelected().get("id");	
							AcdcDistributionMapBO.distmanufacturer = form.distmanufacturer;	
							AcdcDistributionMapBO.ptype = form.ptype;	
							AcdcDistributionMapBO.num = form.num;								 
							AcdcDistributionMapBO.other = form.other;	   
							AcdcDistributionMapBO.record = form.record;
							AcdcDistributionMapBO.recordtype = recordType;
							JAcdcDistributionWeb.saveAcdcDistributionMap(AcdcDistributionMapBO,function(data)
							{
								if(data)
	          					{
	          						_win.hide();
	          						Ext.Msg.alert('成功',"操作成功！",function()
	          						{
										loadEleAndAirdata(cDS,acdcGrid.getSelectionModel().getSelected().get("id"),recordType);		
	          						}); 
									_form.reset(); 
	          					}else
	          					{
	          						Ext.Msg.alert("失败","操作失败!");
	          					}																
							})							
							
						}
					}
				},{
					text : '取消',
					handler : function() {
						_win.hide();
						_form.reset(); 
					},
					tooltip : '关闭对话框'
				}
			]	
		});
	}
	Ext.extend(AcdcAirWindow, Ext.Window); 
	var acdcAirWindow = new AcdcAirWindow();
	
	var acdcEleForm = new Ext.FormPanel({
			//renderTo:'changeTab',
	    	labelAlign: 'right',
	        frame:true,	        
	        labelWidth:150,	       
			anchor:'90%',
			region:'center',
			height: 360,
			minSize: 200,	
			align:'center',
			buttonAlign:'center', 
			border: false, 
			style: 'margin:0 auto',
			layout:'form', 
			margins:'55 35 100 35',	
	        items: [  
					{
						xtype : 'hidden',
						fieldLabel : "id",
						readOnly : true,
						name : "id"
					},
					{
						xtype : 'hidden',
						fieldLabel : "acdcid",
						readOnly : true,
						name : "acdcid"
					},
					{
						xtype:'textfield',
						fieldLabel:'电缆规格',
						emptyText:'电缆规格',
						name : 'distmanufacturer',
						width : 200,
						allowBlank : false,
						blankText : '请输入电缆规格'
					},{
						xtype:'textfield',
						fieldLabel:'电缆类型',
						 emptyText:'电缆类型',
						 name : 'ptype',
						 width : 200,
						 allowBlank : false,
						 blankText : '请输入电缆类型'
					},{
						xtype:'numberfield',
						fieldLabel:'数量（根）',
						emptyText:'数量（根）',
						name : 'num',
						width : 200,
						decimalPrecision:2,
						value:0,
						allowBlank : false,
						blankText : '请输入数量（根）'
					},{
						xtype:'numberfield',
						 fieldLabel:'长度',
						 emptyText:'长度',
						 name : 'len',
						 width : 200,
						 decimalPrecision:2,
						 value:0,
						 allowBlank : false,
						 blankText : '请输入长度'
					},{
						xtype:'textfield',
						fieldLabel: '整治及更换记录',
						name: 'record',
						width:200, 	  
						blankText :'请输入更换记录'
					},{
						xtype:'textfield',
						 fieldLabel:'线缆用途',
						 emptyText:'线缆用途',
						 name : 'userful',
						 width : 200
					},{
						xtype:'textarea',
						fieldLabel:'备注',
						emptyText:'备注',
						name : 'meno',
						width : 200
					}				 
				]		
		}); 	
	
	var AcdcEleWindow = function() {
		var _win = this;
		this.formPanel = acdcEleForm;
		var _form = this.formPanel.getForm();
		AcdcEleWindow.superclass.constructor.call(this, { 
			title: '电缆使用情况',
			width : 450,
			height : 350,
			resizable : true,
			plain : false,
			border : false,
			modal : true,
			autoScroll : false,
			layout : 'fit',
			closeAction : 'hide',
			items : this.formPanel,
			buttonAlign:'center',
			buttons : 
			[
				{	text : ' 保存',
					handler : function() 
					{
						if (_form.isValid()) 
						{
							var form = _form.getValues(false);
							 
							AcdcDistributionMapBO = {};
							AcdcDistributionMapBO.id = form.id;	
							AcdcDistributionMapBO.acdcid = acdcGrid.getSelectionModel().getSelected().get("id");	
							AcdcDistributionMapBO.distmanufacturer = form.distmanufacturer;	
							AcdcDistributionMapBO.ptype = form.ptype;	
							AcdcDistributionMapBO.num = form.num ;	
							AcdcDistributionMapBO.len = form.len;	 
							AcdcDistributionMapBO.meno = form.meno;	
							AcdcDistributionMapBO.userful = form.userful; 
							AcdcDistributionMapBO.record = form.record;
							AcdcDistributionMapBO.recordtype = recordType;
							JAcdcDistributionWeb.saveAcdcDistributionMap(AcdcDistributionMapBO,function(data)
							{
								if(data)
	          					{
	          						_win.hide();
	          						Ext.Msg.alert('成功',"操作成功！",function()
	          						{
										loadEleAndAirdata(cDS,acdcGrid.getSelectionModel().getSelected().get("id"),recordType);		
	          						}); 
									_form.reset(); 
	          					}else
	          					{
	          						Ext.Msg.alert("失败","操作失败!");
	          					}																
							})							
							
						}
					}
				},{
					text : '取消',
					handler : function() {
						_win.hide();
						_form.reset(); 
					},
					tooltip : '关闭对话框'
				}
			]	
		});
	}
	Ext.extend(AcdcEleWindow, Ext.Window); 
	var acdcEleWindow = new AcdcEleWindow();	
	
	
})